package edu.whu.aspect;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author 一个日志Aspect
 */

@Aspect
@Component
public class LogAspect {
    Logger logger = LoggerFactory.getLogger(getClass());

    @Before("execution(public * edu.whu.dao.*.*(..))")
    public void beforeDao(JoinPoint jp){

        String info= "进入"+jp.getSignature()+"方法,";
        info +="参数是：";
        for (Object arg : jp.getArgs()) {
            info+= arg+" ";
        }
        logger.info(info);
    }

    @After("execution(public * edu.whu.dao.UserDao.*(..))")
    public void afterUserDao(JoinPoint jp) {
        logger.info("退出UserDao的方法:"+jp.getSignature());
    }






}
